<template>
  <dl>
    <dt>{{ $t('pageOverview.firmwareInformation') }}</dt>
    <dd></dd>
    <dt v-if="BMCVersion">{{ $t('pageOverview.BMCVersion') }}：</dt>
    <dd v-if="BMCVersion">{{ dataFormatter(BMCVersion) }}</dd>
    <dt v-if="hostVersion">{{ $t('pageOverview.hostVersion') }}：</dt>
    <dd v-if="hostVersion">{{ dataFormatter(hostVersion) }}</dd>
    <dt v-if="PBFVersion">{{ $t('pageOverview.PBFVersion') }}：</dt>
    <dd v-if="PBFVersion">{{ dataFormatter(PBFVersion) }}</dd>
    <dt v-if="cpldVersion">{{ $t('pageOverview.cpldVersion') }}：</dt>
    <dd v-if="cpldVersion">{{ dataFormatter(cpldVersion) }}</dd>
  </dl>
</template>

<script>
import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';

export default {
  name: 'Firmware',
  mixins: [DataFormatterMixin],
  computed: {
    backupBmcFirmware() {
      return this.$store.getters['firmware/backupBmcFirmware'];
    },
    backupVersion() {
      return this.backupBmcFirmware?.version;
    },
    activeBmcFirmware() {
      return this.$store.getters[`firmware/activeBmcFirmware`];
    },
    BMCVersion() {
      return this.activeBmcFirmware?.version;
    },
    activeCpldFirmware() {
      return this.$store.getters[`firmware/activeCpldFirmware`];
    },
    cpldVersion() {
      return this.activeCpldFirmware?.version;
    },
    hostFirmware() {
      return this.$store.getters['firmware/activeHostFirmware'];
    },
    hostVersion() {
      return this.hostFirmware?.version;
    },
    PBFVersion() {
      return this.$store.getters['firmware/activeHostPbfFirmware'];
    },
  },
  created() {
    this.$store.dispatch('firmware/getFirmwareInformation').finally(() => {
      this.$root.$emit('overview-firmware-complete');
    });
  },
};
</script>
<style scoped>
dl > dt:first-child {
  font-weight: bold;
  font-size: 16px;
  padding-bottom: 20px;
}
dl {
  display: grid;
  grid-template-columns: auto 1fr;
  row-gap: 10px;
  column-gap: 10px;
}
</style>
